package com.erp.module.duizhangPhoto

import android.content.Context
import com.erp.Interface.OnUserDataInterface
import com.erp.bean.DuizhangBean
import com.erp.pull.BasePullP
import com.erp.util.JsonUtil
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject

class IDuizhangPhotoP(var list :MutableList<DuizhangBean>, var V : DuizhangPhotoContract.DuizhangPhotoPView, var context: Context) : BasePullP(), DuizhangPhotoContract.DuizhangPhotoP{
    var md = DuizhangPhotoModel()
    init {
        PullV = V
    }
    override fun getData(page: Int, pagesize: Int, onUserDataInterface: OnUserDataInterface) {
        md.getDuizhangList(context,page,pagesize,onUserDataInterface)
    }

    override fun jsondata(data: String?) {
        if (data==null){
            return
        }
        try {
            val j = JSONObject(data)
            val js = JsonUtil.getjsvolue(j,"data")
            for (i in 0 until js.length()) {
                val bean = DuizhangBean()
                val jo = js.get(i) as JSONObject
                bean.id = JsonUtil.getvolue(jo, "id")
                bean.year = JsonUtil.getvolue(jo, "year")
                bean.month = JsonUtil.getvolue(jo, "month")
                bean.audit_time = JsonUtil.getvolue(jo, "audit_time")
                list.add(bean)
            }
        } catch (e: JSONException) {
            e.printStackTrace()

        }
    }

    override fun listClean() {
        list.clear()
    }
}